﻿'/* Copyright (c) 2009, Graeme Grant (graeme@live.com.au)
' * All rights reserved.
' *
' * Redistribution and use in source and binary forms, with or without
' * modification, are permitted provided that the following conditions are met:
' *
' *   * Redistributions of source code must retain the above copyright
' *     notice, this list of conditions and the following disclaimer.
' * 
' *   * Redistributions in binary form must reproduce the above copyright
' *     notice, this list of conditions and the following disclaimer in the
' *     documentation and/or other materials provided with the distribution.
' * 
' *   * The name Graeme Grant may not be used to endorse or promote products
' *     derived from this software without specific prior written permission.
' *
' * THIS SOFTWARE IS PROVIDED BY GRAEME GRANT ``AS IS'' AND ANY
' * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
' * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
' * DISCLAIMED. IN NO EVENT SHALL Dr. WPF BE LIABLE FOR ANY
' * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
' * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
' * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
' * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
' * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
' * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
' */

Imports System.Xml.Serialization
Imports System.IO

<Serializable()> _
Public Class Method

#Region "Constructor"

    Public Sub New()

    End Sub

    Public Sub New(ByVal Details As Hashtable)
        ExtractDetails(Details)
    End Sub

    Friend Sub New(ByVal _json As String)
        ExtractDetails(CType(JSON.JsonDecode(_json), Hashtable)("results")(0))
    End Sub

#End Region

#Region "Public Properties"

    <XmlElement("name")> _
    Private _name As String
    Public Property Name() As String
        Get
            Return _name
        End Get
        Set(ByVal value As String)
            _name = value
        End Set
    End Property

    <XmlElement("description")> _
    Private _description As String
    Public Property Description() As String
        Get
            Return _description
        End Get
        Set(ByVal value As String)
            _description = value
        End Set
    End Property

    <XmlElement("uri")> _
    Private _uri As String
    Public Property URI() As String
        Get
            Return _uri
        End Get
        Set(ByVal value As String)
            _uri = value
        End Set
    End Property

    <XmlElement("params")> _
    Private _params As Hashtable
    Public Property Params() As Hashtable
        Get
            Return _params
        End Get
        Set(ByVal value As Hashtable)
            _params = value
        End Set
    End Property

    <XmlElement("type")> _
    Private _type As String
    Public Property Type() As String
        Get
            Return _type
        End Get
        Set(ByVal value As String)
            _type = value
        End Set
    End Property

    <XmlElement("http_method")> _
    Private _http_method As String
    Public Property HTTP_Method() As String
        Get
            Return _http_method
        End Get
        Set(ByVal value As String)
            _http_method = value
        End Set
    End Property

#End Region

#Region "Support Methods & Functions"

    Private Sub ExtractDetails(ByVal Details As Hashtable)

        _name = Details("name")
        _description = Details("description")
        _uri = Details("uri")
        _params = Details("params")
        _type = Details("type")
        _http_method = Details("http-method")

    End Sub

#End Region

End Class
